<ui:composition template="/WEB-INF/templates/template.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core">

	<ui:define name="conteudo">
		<h:form id="form">
			<p:panel id="panel" header="Cadastro de Instituições">
				<h:inputHidden value="#{instituicaoBean.instituicao.id}" />
				<h:panelGrid columns="6">
					<p:outputLabel value="Nome: " for="nome" />
					<p:inputText id="nome" value="#{instituicaoBean.instituicao.nome}"
						required="true" />
					<p:message for="nome" />

					<p:outputLabel value="Endereço: " for="endereco" />
					<p:inputText id="endereco"
						value="#{instituicaoBean.instituicao.endereco}" />
					<p:message for="endereco" />

					<p:outputLabel value="Cidade: " for="cidade" />
					<p:inputText id="cidade"
						value="#{instituicaoBean.instituicao.cidade}" />
					<p:message for="cidade" />

					<p:outputLabel value="Telefone: " for="telefone" />
					<p:inputText id="telefone"
						value="#{instituicaoBean.instituicao.telefone}" />
					<p:message for="telefone" />
					<p:outputLabel value="Tipo: " for="tipo" />
					<p:selectOneMenu id="tipo" value="#{instituicaoBean.instituicao.tipo}">
						<f:selectItem itemLabel="Selecionar" itemValue="" />
						<f:selectItem itemLabel="Clínica" itemValue="Clínica" />
						<f:selectItem itemLabel="Láboratorio" itemValue="Láboratorio" />
					</p:selectOneMenu>
					<p:message for="tipo" />


				</h:panelGrid>
				<p:commandButton value="Cadastrar"
					actionListener="#{instituicaoBean.add}" update="form,:lista" />
				<p:commandButton value="Atualizar" update=":lista" />
			</p:panel>
		</h:form>
		<h:form id="lista">
			<p:panel header="Lista de Instituições">
				<p:dataTable id="instituicaos" var="instituicao"
					value="#{instituicaoBean.instituicoes}" paginator="true" rows="3">

					<p:column headerText="Nome" style="width:20%">
						<h:outputText value="#{instituicao.nome}" />
					</p:column>

					<p:column headerText="Telefone" style="width:20%">
						<h:outputText value="#{instituicao.telefone}" />
					</p:column>

					<p:column headerText="Endereço" style="width:20%">
						<h:outputText value="#{instituicao.endereco}" />
					</p:column>
					<p:column headerText="Tipo" style="width:20%">
						<h:outputText value="#{instituicao.tipo}" />
					</p:column>
					<p:column headerText="Cidade" style="width:20%">
						<h:outputText value="#{instituicao.cidade}" />
					</p:column>
					
					<p:column style="width:24%">
						<p:commandButton update=":form" value="Editar"
							actionListener="#{instituicaoBean.preparaAlteracao}">
							<f:param name="id" value="#{instituicao.id}" />
						</p:commandButton>
					</p:column>
					<p:column style="width:24%">
						<p:commandButton update=":lista" value="Remover"
							actionListener="#{instituicaoBean.remove}">
							<f:param name="id" value="#{instituicao.id}" />
						</p:commandButton>
					</p:column>
				</p:dataTable>
			</p:panel>
		</h:form>

	</ui:define>
</ui:composition>